package ui.prototypes;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class CashFlowDatabaseHelper extends SQLiteOpenHelper {

    private static final String DATABASE = "test";

    private static final int DATABASE_VERSION = 2;

    private static final String TEST_SQL = "CREATE TABLE " + CashFlowContract.CashFlowTable.TABLE_NAME +
        " (" + CashFlowContract.CashFlowTable.ID + " integer primary key autoincrement," +
               CashFlowContract.CashFlowTable.DESCRIPTION + " text," +
               CashFlowContract.CashFlowTable.VALUE + " real," +
               CashFlowContract.CashFlowTable.DATE + " integer)";

    public CashFlowDatabaseHelper(Context context) {
        super(context, DATABASE, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(TEST_SQL);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
        db.execSQL("DROP TABLE IF EXISTS " + CashFlowContract.CashFlowTable.TABLE_NAME);
        onCreate(db);
    }

}
